package com.example.leetcode.string;

import com.example.leetcode.string.common.StringUtils;

class SolutionOffer20 {
    public boolean isNumber(String s) {
//        return StringUtils.isNumber(s);
        return StringUtils.isNumber2(s);
    }
}

public class offer20 {
    public static void main(String[] args) {
        SolutionOffer20 solutionOffer20 = new SolutionOffer20();

        System.out.println(solutionOffer20.isNumber("12e"));

        testT(solutionOffer20);
        testF(solutionOffer20);
    }

    private static void testF(SolutionOffer20 solutionOffer20) {
        System.out.println("        ---false---");
        String[] strs2 = {"12e", "1a3.14", "1.2.3", "+-5", "12e+5.4", ".", "e9", "0..", "7e69e", "4e+"};
        for (String s : strs2) {
            System.out.printf("%10s -> %5s%n", s, solutionOffer20.isNumber(s));
        }
    }

    private static void testT(SolutionOffer20 solutionOffer20) {
        System.out.println("        ---true---");
        String[] strs = {"+100", "5e2", "-123", "3.1416", "-1E-16", "0123", ".1"};
        for (String s : strs) {
            System.out.printf("%10s -> %5s%n", s, solutionOffer20.isNumber(s));
        }
    }
}
